﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;

namespace CungMuaC5.Account_Admin
{
    public partial class DanhSachComment : System.Web.UI.Page
    {
        int MaCM = 0;
        public void Page_Load(object sender, EventArgs e)
        {
            try
            {
                MaCM = int.Parse(Request.QueryString["ma"].ToString());
            }
            catch (Exception ex)
            {

            }
            if (!IsPostBack || MaCM==0)
            {

                FillGridView1();
                
            }
            if (MaCM != 0)
            {
                Update();
                FillGridView1();
            }
                


        }

        private void Update()
        {
            BUS_Comment bus = new BUS_Comment();
            bool i = bus.Delete(MaCM);
        }

        private void FillGridView1()
        {
            BUS_Comment bus = new BUS_Comment();
            GridView1.DataSource = bus.dto();
            GridView1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            BUS_Comment bus = new BUS_Comment();
            string ten = TextBox2.Text;
            GridView1.DataSource = bus.TimKiemTheoTen(ten);
            GridView1.DataBind();
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs egri)
        {
            GridView1.PageIndex = egri.NewPageIndex;
            FillGridView1(); 
        }

        protected void TextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            BUS_Comment bus = new BUS_Comment();
            string KM = TextBox1.Text;
            GridView1.DataSource = bus.TimKiemTheoKM(KM);
            GridView1.DataBind();
        }

    }
}